#include "aicommandaction.h"

namespace IAlib
{

AiCommandAction::AiCommandAction()
{
    AiCommand::setType(COMMAND_AI_ACTION);
}

QByteArray AiCommandAction::toByteArray() const
{
    QByteArray byte_array;
    QDataStream data(&byte_array, QIODevice::WriteOnly);

    data<<getMode();
    data<<getAgentId();
    data<<getActionName();
    data<<getActionState();

    return byte_array;
}

void AiCommandAction::fromByteArray(QByteArray &byte_array)
{
    QDataStream data(&byte_array, QIODevice::ReadOnly);
    int i_temp;
    QString s_temp;
    data>>i_temp;
    setMode((CommandMode)i_temp);
    data>>s_temp;
    setAgentId(s_temp);
    data>>s_temp;
    setActionName(s_temp);
    data>>i_temp;
    setActionState((ActionState)i_temp);
}

}
